/*******************************************************************************
 * 创建: 2024年08月28日
 * 作者: 水煮肉片饭(27185709@qq.com)
 * 描述: 拖拽器，游戏中可以按住该节点进行拖拽
*******************************************************************************/
import { _decorator, Component, NodeEventType, EventTouch } from "cc";
const { ccclass, menu } = _decorator;
@ccclass
@menu('Gi/Dragger')
export class Dragger extends Component {
    protected onEnable() {
        this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
    }
    protected onDisable() {
        this.node.off(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
    }
    private onTouchMove(event: EventTouch) {
        let pos = this.node.position;
        let delt = event.getUIDelta();
        this.node.setPosition(pos.x + delt.x, pos.y + delt.y);
    }
}